package com.jxkj.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * 项目: shop-car
 * <p>
 * 功能描述: 购物车session共享配置
 *
 * @author: WuChengXing
 * @create: 2020-08-11 00:27
 **/
@Configuration
public class CartCookieConfig {

    /**
     * Cookie的相关配置
     * @return
     */
    @Bean
    public CookieSerializer cookieSerializer() {
        DefaultCookieSerializer defaultCookieSerializer = new DefaultCookieSerializer();
        defaultCookieSerializer.setDomainName("localhost");
        defaultCookieSerializer.setCookieName("wcx");
        return defaultCookieSerializer;
    }

    @Bean
    public RedisSerializer<Object> serializer() {
        return new GenericJackson2JsonRedisSerializer();
    }

}
